<template>
  <div>
    <a-modal
      :maskClosable="false"
      :keyboard="false"
      centered
      :title="title"
      :width="width"
      :visible="visible"
      @ok="handleOk"
      @cancel="handleCancel"
      :cancelText="$t('m.common.button.close')">
      <a-row type="flex" :gutter="16">
        <a-col :md="5" :sm="24">
          <sys-org-tree @onSelect="select" :selectedRoot="true"></sys-org-tree>
        </a-col>
        <a-col :md="24-5" :sm="24">
          <select-user-tree-right ref="user" v-model="currentOrgCode"/>
        </a-col>
      </a-row>
    </a-modal>
  </div>
</template>

<script>
  import SelectUserTreeRight from './SelectUserTreeRight'
  import SysOrgTree from '../../../components/ych/ych-org/SysOrgTree'

  export default {
    name: 'SelectUserTreeModal',
    components: {SysOrgTree, SelectUserTreeRight},
    data() {
      return {
        title: this.$t('m.system.user.other.add_user'),
        width: '90%',
        visible: false,
        description: '选用户',
        currentOrgCode: ''
      }
    },

    methods: {
      select(deptId, orgCode){
        this.currentOrgCode = orgCode;
      },
      handleOk() {
        const selectRows = this.$refs.user.selectionRows;
        this.$emit("selectFinished", undefined, selectRows);
        this.$refs.user.selectedRowKeys = [];
        this.$refs.user.selectionRows = [];
        this.visible = false;
      },
      handleCancel() {
        this.$refs.user.selectedRowKeys = [];
        this.$refs.user.selectionRows = [];
        this.visible = false;
      },
    }
  }
</script>
<style lang="less" scoped>

</style>
